Friend Class CheckBoxListConverter
    Inherits System.ComponentModel.StringConverter

    ''' <summary>
    ''' Checks the page context to see if standard values are supported.
    ''' </summary>
    ''' <param name="context">The web page's context object.</param>
    ''' <returns>A boolean true/false value.</returns>
    ''' <remarks></remarks>
    Public Overloads Overrides Function GetStandardValuesSupported(ByVal context As ComponentModel.ITypeDescriptorContext) As Boolean
        Return True
    End Function
    ''' <summary>
    ''' Parses the page context and finds all CheckBoxList IDs.
    ''' </summary>
    ''' <param name="context">The web page's context object.</param>
    ''' <returns>A StandardValuesCollection of CheckBoxList IDs.</returns>
    ''' <remarks></remarks>
    Public Overloads Overrides Function GetStandardValues(ByVal context As ComponentModel.ITypeDescriptorContext) As StandardValuesCollection
        Dim CheckBoxListArrayList As New ArrayList
        For Each Control As System.Web.UI.Control In context.Container.Components
            Try
                If Control.GetType Is GetType(System.Web.UI.WebControls.CheckBoxList) Then
                    If Control.ID.StartsWith("_ctl") Then
                        CheckBoxListArrayList.Add(Control.ID.Remove(1, Control.ID.ToString.IndexOf("_"c, 1) + 1))
                    Else
                        CheckBoxListArrayList.Add(Control.ID)
                    End If
                End If
            Catch ex As Exception
                Throw
            End Try
        Next
        Return New StandardValuesCollection(CheckBoxListArrayList)
    End Function
End Class